From: Giovanni Campagna Date: Wed, 11 Sep 2013 16:11:55 +0000 (+0200) Subject: StEntry: add a hook to set the cursor from libgnome-shell X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~3447 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=8ae0f1a9dc20e2f59b4fc777748c0e1871cbcaf9;p=gnome-shell.git StEntry: add a hook to set the cursor from libgnome-shell We need to call into MetaScreen to set the cursor, but we can't do that from libst, so add a hook that libgnome-shell can fill, and remove more ClutterX11 usage. https://bugzilla.gnome.org/show_bug.cgi?id=707467 --- diff --git a/src/shell-global.c b/src/shell-global.c index 97cdebd2c..3f85ac501 100644 --- a/src/shell-global.c +++ b/src/shell-global.c @@ -828,6 +828,16 @@ gnome_shell_gdk_event_handler (GdkEvent *event_gdk, gtk_main_do_event (event_gdk); } +static void +entry_cursor_func (StEntry *entry, + gboolean use_ibeam, + gpointer user_data) +{ + ShellGlobal *global = user_data; + + meta_screen_set_cursor (global->meta_screen, use_ibeam ? META_CURSOR_IBEAM : META_CURSOR_DEFAULT); +} + void _shell_global_set_plugin (ShellGlobal *global, MetaPlugin *plugin) @@ -878,6 +888,7 @@ _shell_global_set_plugin (ShellGlobal *global, } st_im_text_set_event_window (global->ibus_window); + st_entry_set_cursor_func (entry_cursor_func, global); g_signal_connect (global->stage, "notify::width", G_CALLBACK (global_stage_notify_width), global); diff --git a/src/st/st-entry.c b/src/st/st-entry.c index c00caa47a..8fec0f4e8 100644 --- a/src/st/st-entry.c +++ b/src/st/st-entry.c @@ -65,10 +65,6 @@ #include "st-clipboard.h" #include "st-private.h" -#include -#include -#include - #include "st-widget-accessible.h" #define HAS_FOCUS(actor) (clutter_actor_get_stage (actor) && clutter_stage_get_key_focus ((ClutterStage *) clutter_actor_get_stage (actor)) == actor) @@ -681,33 +677,28 @@ st_entry_key_focus_in (ClutterActor *actor) clutter_actor_grab_key_focus (priv->entry); } +static StEntryCursorFunc cursor_func; +static gpointer cursor_func_data; + +/** + * st_entry_set_cursor_func: (skip) + * + * This function is for private use by libgnome-shell. + * Do not ever use. + */ +void +st_entry_set_cursor_func (StEntryCursorFunc func, + gpointer data) +{ + cursor_func = func; + cursor_func_data = data; +} + static void st_entry_set_cursor (StEntry *entry, gboolean use_ibeam) { - Display *dpy; - ClutterActor *stage, *actor = CLUTTER_ACTOR (entry); - Window wid; - static Cursor ibeam = None; - - dpy = clutter_x11_get_default_display (); - stage = clutter_actor_get_stage (actor); - - if (stage == NULL) - { - g_warn_if_fail (!entry->priv->has_ibeam); - return; - } - - wid = clutter_x11_get_stage_window (CLUTTER_STAGE (stage)); - - if (ibeam == None) - ibeam = XCreateFontCursor (dpy, XC_xterm); - - if (use_ibeam) - XDefineCursor (dpy, wid, ibeam); - else - XUndefineCursor (dpy, wid); + cursor_func (entry, use_ibeam, cursor_func_data); entry->priv->has_ibeam = use_ibeam; } diff --git a/src/st/st-entry.h b/src/st/st-entry.h index ebe95bf44..bc79db4ec 100644 --- a/src/st/st-entry.h +++ b/src/st/st-entry.h @@ -86,6 +86,10 @@ void st_entry_set_primary_icon (StEntry *entry, void st_entry_set_secondary_icon (StEntry *entry, ClutterActor *icon); +typedef void (*StEntryCursorFunc) (StEntry *entry, gboolean use_ibeam, gpointer data); +void st_entry_set_cursor_func (StEntryCursorFunc func, + gpointer user_data); + G_END_DECLS #endif /* __ST_ENTRY_H__ */